<!doctype html>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script src="../assert_selection.js"></script>
<script>
    // Test for http://wkb.ug/30892
    test(() => assert_selection(
        '<div contenteditable>^01|2345</div>',
        selection => {
            selection.document.execCommand('hilitecolor', false, '#FF0000');
            selection.document.execCommand('undo');
            selection.document.execCommand('redo');
        },
        [
            '<div contenteditable>',
            '<span style="background-color: rgb(255, 0, 0);">^01|</span>2345',
            '</div>',
        ].join('')),
        'Hilite 01');

    test(() => assert_selection(
        '<div contenteditable>01^23|45</div>',
        selection => {
            selection.document.execCommand('hilitecolor', false, '#FF0000');
            selection.document.execCommand('undo');
            selection.document.execCommand('redo');
        },
        [
            '<div contenteditable>',
            '01<span style="background-color: rgb(255, 0, 0);">^23|</span>45',
            '</div>',
        ].join('')),
        'Hilite 23');

    test(() => assert_selection(
        '<div contenteditable>0123^45|</div>',
        selection => {
            selection.document.execCommand('hilitecolor', false, '#FF0000');
            selection.document.execCommand('undo');
            selection.document.execCommand('redo');
        },
        [
            '<div contenteditable>',
            '0123<span style="background-color: rgb(255, 0, 0);">^45|</span>',
            '</div>',
        ].join('')),
        'Hilite 45');
</script>
